﻿// See https://aka.ms/new-console-template for more information
using Newtonsoft.Json;

namespace StudyDemo.GenericParadigm;

public partial class DouleVector
{
    #region 泛型限定类型
    //DouleVector douleVector = new DouleVector();
    //douleVector.Attack(new FloatVector(1, 2), new FloatVector(3, 4));
    #endregion

    /// <summary>
    /// 限定泛型T必须是FloatVector类型示例
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="a"></param>
    /// <param name="b"></param>
    public void Attack<T>(T a, T b)
        where T : StudyDemo.GenericParadigm.FloatVector
    {
        Console.WriteLine("Attacking with {0} and {1}", JsonConvert.SerializeObject(a), JsonConvert.SerializeObject(b));
    }
}
